<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('添加中心介绍')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-add-notice">
        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-9">
                    <input class="form-control required" type="text" id="title">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-9">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content no-padding">
                            <div class="summernote required" id="content">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: summernote-js"/>
<script>
    var prefix = ctx + "system/touchscreen/helpinfo";
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN',
            height: 300,
            minHeight: null,
            maxHeight: null,
        });
    });
    $("#form-add-notice").validate({
        onkeyup: false,
        rules: {
            title: {
                minlength: 1,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var title = $('#title').val();
            var content = $('#content').summernote('code');
            if (content.length > 1) {
                var data = $("#form-add-notice").serializeArray();
                console.log(content);
                data.push({"name": "title", "value": title});
                data.push({"name": "content", "value": content});
                $.operate.save(prefix + "/add", data);
            } else {
                alert('请填写介绍');
            }
        }
    }
</script>
</body>
</html>
